/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.taobao.ibatiside.model.configv3.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.taobao.ibatiside.model.configv3.Configv3Package;
import org.taobao.ibatiside.model.configv3.EnvironmentType;
import org.taobao.ibatiside.model.configv3.EnvironmentsType;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Environments Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.taobao.ibatiside.model.configv3.impl.EnvironmentsTypeImpl#getEnvironment <em>Environment</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.configv3.impl.EnvironmentsTypeImpl#getDefault <em>Default</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class EnvironmentsTypeImpl extends EObjectImpl implements EnvironmentsType {
	/**
	 * The cached value of the '{@link #getEnvironment() <em>Environment</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEnvironment()
	 * @generated
	 * @ordered
	 */
	protected EList<EnvironmentType> environment;

	/**
	 * The cached value of the '{@link #getDefault() <em>Default</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDefault()
	 * @generated
	 * @ordered
	 */
	protected EObject default_;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EnvironmentsTypeImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Configv3Package.Literals.ENVIRONMENTS_TYPE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<EnvironmentType> getEnvironment() {
		if (environment == null) {
			environment = new EObjectContainmentEList<EnvironmentType>(EnvironmentType.class, this, Configv3Package.ENVIRONMENTS_TYPE__ENVIRONMENT);
		}
		return environment;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EObject getDefault() {
		return default_;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDefault(EObject newDefault) {
		EObject oldDefault = default_;
		default_ = newDefault;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Configv3Package.ENVIRONMENTS_TYPE__DEFAULT, oldDefault, default_));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Configv3Package.ENVIRONMENTS_TYPE__ENVIRONMENT:
				return ((InternalEList<?>)getEnvironment()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Configv3Package.ENVIRONMENTS_TYPE__ENVIRONMENT:
				return getEnvironment();
			case Configv3Package.ENVIRONMENTS_TYPE__DEFAULT:
				return getDefault();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Configv3Package.ENVIRONMENTS_TYPE__ENVIRONMENT:
				getEnvironment().clear();
				getEnvironment().addAll((Collection<? extends EnvironmentType>)newValue);
				return;
			case Configv3Package.ENVIRONMENTS_TYPE__DEFAULT:
				setDefault((EObject)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Configv3Package.ENVIRONMENTS_TYPE__ENVIRONMENT:
				getEnvironment().clear();
				return;
			case Configv3Package.ENVIRONMENTS_TYPE__DEFAULT:
				setDefault((EObject)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Configv3Package.ENVIRONMENTS_TYPE__ENVIRONMENT:
				return environment != null && !environment.isEmpty();
			case Configv3Package.ENVIRONMENTS_TYPE__DEFAULT:
				return default_ != null;
		}
		return super.eIsSet(featureID);
	}

} //EnvironmentsTypeImpl
